package com.seari.web.controller;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.seari.Utils.DateUtil;
import com.seari.Utils.StringUtils;
import com.seari.bean.EventMessageBean;
import com.seari.commonutils.redis.JedisUtilProxy;
import com.seari.commonutils.redis.ex.JedisNotInitializeException;
import com.seari.main.StartUpClass;
import com.seari.pojo.MessageBean;
import com.seari.pojo.QueryEventMessage;
import com.seari.service.IndexService;
import com.seari.service.StationEventService;

import redis.clients.jedis.Jedis;

@Controller
public class IndexController {

	@Autowired
	private IndexService is;
	
	@Autowired
	private StationEventService stationEventService;
	
	private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");

	@RequestMapping("index")
	public String index() {
		return "index";
	}
	
	@RequestMapping("gzzx")
	public String gzzx() {
		return "gzzx";
	}

	/**
	 * 首页温湿度
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/monitor")
	@ResponseBody
	public MessageBean monitorData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> monitorData = new HashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.monitor)) {
				monitorData.put("temperature", "31℃");
				monitorData.put("precipitation", "54%");
				int PM = (int) (35 + Math.random() * (11));
				monitorData.put("pm2", PM);
				monitorData.put("ppm", "450");
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				// 温度
				List<String> tempList = jedis.hmget("17DATA", "531", "532", "533", "534", "535", "536", "537", "538");
				int tempAll = 0;
				for (int i = 0; i < tempList.size(); i++) {
					tempAll = tempAll + Integer.parseInt(tempList.get(i));
				}
				monitorData.put("temperature", (int)((tempAll / tempList.size())*0.1) + "℃");

				// 湿度
				List<String> humidityList = jedis.hmget("17DATA", "539", "540", "541", "542", "543", "544", "545",
						"546");
				int humidityAll = 0;
				for (int i = 0; i < humidityList.size(); i++) {
					humidityAll = humidityAll + Integer.parseInt(humidityList.get(i));
				}
				monitorData.put("precipitation", (int)((humidityAll / humidityList.size())*0.1) + "%");

				// pm2.5
//				int PM = (int) (35 + Math.random() * (11));
//				monitorData.put("pm2", PM);

				// 二氧化碳
				List<String> ppmList = jedis.hmget("17DATA", "547", "548", "549", "550", "551", "552", "553", "554");
				int ppmAll = 0;
				for (int i = 0; i < ppmList.size(); i++) {
					ppmAll = ppmAll + Integer.parseInt(ppmList.get(i));
				}
				monitorData.put("ppm", (int)((ppmAll / ppmList.size())*0.1) );

			}
			dataMap.put("monitorData", monitorData);
			messageBean.setType("success");
			messageBean.setMessage("温湿度数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("温湿度数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 系统总览
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/systemOverview")
	@ResponseBody
	public MessageBean getSystemOverviewData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> systemOverview = new LinkedHashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.systemOverview)) {
				systemOverview.put("EMCS", true);
				systemOverview.put("FAS", true);
				systemOverview.put("AFC", true);
				systemOverview.put("ACS", true);
				systemOverview.put("PSD", true);
				systemOverview.put("PA", true);
				systemOverview.put("CCTV", true);
				systemOverview.put("PIS", true);
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				List<String> EMCS = jedis.hmget("17DATA", "8478", "8479");
				systemOverview.put("EMCS", StringUtils.deviceStatus0(EMCS));
				List<String> FAS = jedis.hmget("17DATA", "8472");
				systemOverview.put("FAS", StringUtils.deviceStatus1(FAS));
				List<String> AFC = jedis.hmget("17DATA", "8476");
				systemOverview.put("AFC", StringUtils.deviceStatus1(AFC));
				List<String> ACS = jedis.hmget("17DATA", "8474");
				systemOverview.put("ACS", StringUtils.deviceStatus1(ACS));
				List<String> PSD = jedis.hmget("17DATA", "8473");
				systemOverview.put("PSD", StringUtils.deviceStatus1(PSD));			
				List<String> PA = jedis.hmget("17DATA", "8480");
				systemOverview.put("PA", StringUtils.deviceStatus0(PA));
				List<String> CCTV = jedis.hmget("17DATA", "9188");
				systemOverview.put("CCTV", StringUtils.deviceStatus0(CCTV));
				List<String> PIS = jedis.hmget("17DATA", "8475");
				systemOverview.put("PIS", StringUtils.deviceStatus1(PIS));
				
                                
				JedisUtilProxy.close(jedis);
			}
			dataMap.put("systemOverviewData", systemOverview);
			messageBean.setType("success");
			messageBean.setMessage("系统总览数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("系统总览数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 车站运营模式
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/operationMode")
	@ResponseBody
	public MessageBean getOperationModeData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> operationModeMap = new HashMap<String, Object>();
		String[] publicArea = new String[2];
		String intelligence = new String();
		try {
			if ("test".equals(StartUpClass.operationMode)) {
				publicArea[0] = "空调季";
				publicArea[1] = "节能通风模式";
				intelligence = "节能模式";
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				int aeration = Integer.parseInt(jedis.hmget("17DATA", "11").get(0));
				// 判断通风系统运行模式
				if (aeration == 1) {
					publicArea[0] = "空调季";
					publicArea[1] = "最小新风空调I";
				} else if (aeration == 2) {
					publicArea[0] = "空调季";
					publicArea[1] = "全新风空调II";
				} else if (aeration == 3) {
					publicArea[0] = "空调季";
					publicArea[1] = "全新风空调II'";
				} else if (aeration == 4) {
					publicArea[0] = "通风季";
					publicArea[1] = "通风III";
				} else if (aeration == 5) {
					publicArea[0] = "通风季";
					publicArea[1] = "通风III'";
				} else if (aeration == 6) {
					publicArea[0] = "通风季";
					publicArea[1] = "通风III''";
				} else if (aeration == 7) {
					publicArea[0] = "停运";
					publicArea[1] = "I端";
				} else if (aeration == 8) {
					publicArea[0] = "停运";
					publicArea[1] = "II端";
				}
				if (aeration == 0 || aeration > 8) {
					publicArea[0] = "无";
					publicArea[1] = "模式";
				}

				List<String> lighting = jedis.hmget("17DATA", "7845", "7846", "7847", "7848");
				// 判断照明系统运行模式
				if ("1".equals(lighting.get(0)) && "0".equals(lighting.get(1)) && "0".equals(lighting.get(2))
						&& "0".equals(lighting.get(3))) {
					intelligence = "运营模式";
				} else if ("0".equals(lighting.get(0)) && "1".equals(lighting.get(1)) && "0".equals(lighting.get(2))
						&& "0".equals(lighting.get(3))) {
					intelligence = "节能模式";
				} else if ("0".equals(lighting.get(0)) && "0".equals(lighting.get(1)) && "1".equals(lighting.get(2))
						&& "0".equals(lighting.get(3))) {
					intelligence = "夜间模式";
				} else if ("0".equals(lighting.get(0)) && "0".equals(lighting.get(1)) && "0".equals(lighting.get(2))
						&& "1".equals(lighting.get(3))) {
					intelligence = "全关模式";
				} else {
					//均不符合时，默认节能模式
					intelligence = "节能模式";
				}
				JedisUtilProxy.close(jedis);
			}
			operationModeMap.put("publicArea", publicArea);
			operationModeMap.put("intelligence", intelligence);
			dataMap.put("operationModeData", operationModeMap);
			messageBean.setType("success");
			messageBean.setMessage("系统运营模式数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("系统运营模式数据获取失败");
		}

		return messageBean;
	}

	/**
	 * 车站运营记录
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/operationalEvent")
	@ResponseBody
	public MessageBean getOperationalEventData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		List<String> resultList = new ArrayList<>();
		try {
			if ("test".equals(StartUpClass.operationalEvent)) {
				resultList.add("6:00@一键开关站开站实行");
				resultList.add("6:30@站厅扶梯1发生故障");
				resultList.add("7:00@站厅扶梯2发生故障");
				resultList.add("7:30@站厅扶梯3发生故障");
				dataMap.put("operationalEventData", resultList);
			} else {
				QueryEventMessage queryEventMessage = new QueryEventMessage();
				//查询当天所有未恢复事件
				queryEventMessage.setHasRecovered(false);
				queryEventMessage.setEventTime(new Timestamp(DateUtil.currentDay().getTime()));
				List<EventMessageBean> eventMessageBeans = stationEventService.getEventMessageByParams(queryEventMessage);
				resultList.add("5:30@一键开关站开站实行"); //假数据
				for(int i = 0; i< eventMessageBeans.size() && i < 5;i++)
				{
					EventMessageBean eventMessageBean = eventMessageBeans.get(i);
					if("CCTV".equals(eventMessageBean.getType()))
					{
						//CCTV报警特殊处理
						 String message = StartUpClass.alarmConfigMap.get(eventMessageBean.getSzCameraId()+"@"+eventMessageBean.getnAlarmType());
						 if(org.apache.commons.lang3.StringUtils.isBlank(message))
						 {
							 //当视频报警配置中无此配置时，采用默认eventMessageBean中的message作为报警信息
							 message = eventMessageBean.getMessage().trim().replace("17_", "");
						 }
						 if(org.apache.commons.lang3.StringUtils.isBlank(eventMessageBean.getAlarmID()))
						 {
							resultList.add(simpleDateFormat.format(eventMessageBean.getEventTime())+"@"+ message);
						 }else {
							resultList.add(simpleDateFormat.format(eventMessageBean.getEventTime())+"@"+ message + "@" + eventMessageBean.getAlarmID());
						 }
					}else {
						if(org.apache.commons.lang3.StringUtils.isBlank(eventMessageBean.getAlarmID()))
						{
							resultList.add(simpleDateFormat.format(eventMessageBean.getEventTime())+"@"+ eventMessageBean.getMessage());
						}else {
							resultList.add(simpleDateFormat.format(eventMessageBean.getEventTime())+"@"+ eventMessageBean.getMessage() + "@" + eventMessageBean.getAlarmID());
						}
					}
				}
				dataMap.put("operationalEventData", resultList);
			}
			messageBean.setType("success");
			messageBean.setMessage("车站运营事件数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("车站运营事件数据获取失败");
		}

		return messageBean;
	}

	/**
	 * 车站客流趋势
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/trend")
	@ResponseBody
	public MessageBean getTrendData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> trendMap = new HashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.trend)) {
				String[] trendTime = { "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00" };
				int[] inTrend = { 740, 738, 644, 344, 443, 541, 645 };
				int[] outTrend = { 446, 445, 337, 439, 541, 444, 347 };
				trendMap.put("trendTime", trendTime);
				trendMap.put("inTrend", inTrend);
				trendMap.put("outTrend", outTrend);
				dataMap.put("trendData", trendMap);
			} else {
				Map<String, String> DBMap = is.getKLData();
				String[] trendTime = DBMap.get("time").split(",");
				int[] inTrend = StringUtils.StringToInt(DBMap.get("in").split(","));
				int[] outTrend = StringUtils.StringToInt(DBMap.get("out").split(","));
				trendMap.put("trendTime", trendTime);
				trendMap.put("inTrend", inTrend);
				trendMap.put("outTrend", outTrend);
				dataMap.put("trendData", trendMap);
			}
			messageBean.setType("success");
			messageBean.setMessage("车站客流趋势数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("车站客流趋势数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 区域客流密度
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/density")
	@ResponseBody
	public MessageBean getDensityData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> densityMap = new HashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.density)) {
				String[] areaDensity = { "2号出入口", "3号出入口", "上行站台", "下行站台" };
				int[] passengerDensity = { 40, 70, 90, 50 };
				densityMap.put("areaDensity", areaDensity);
				densityMap.put("passengerDensity", passengerDensity);
				dataMap.put("densityData", densityMap);
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				// redis中key:value 16:2号出入口 17:3号出去口 18:上行站台 19:下行站台
				List<String> dataList = jedis.hmget("OTHER_DATA", "16", "17", "18", "19");
				JedisUtilProxy.close(jedis);
				densityMap.put("areaDensity", dataList);
				dataMap.put("densityData", densityMap);
			}
			messageBean.setType("success");
			messageBean.setMessage("区域客流密度数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("区域客流密度数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 人员页任务信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/personInfo")
	@ResponseBody
	public MessageBean getPersonInfoData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> personInfoMap = new HashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.personInfo)) {
				int[] positionStatus = { 15, 10, 2 };
				String[] person = { "站长", "值班员", "站务员" };
				int[] planWork = { 80, 70, 100 };
				int[] planComplete = { 60, 50, 70 };
				int[] perceptionWork = { 70, 55, 75 };
				int[] perceptionComplete = { 70, 55, 75 };
				personInfoMap.put("positionStatus", positionStatus);
				personInfoMap.put("person", person);
				personInfoMap.put("planWork", planWork);
				personInfoMap.put("planComplete", planComplete);
				personInfoMap.put("perceptionWork", perceptionWork);
				personInfoMap.put("perceptionComplete", perceptionComplete);
				dataMap.put("personInfoData", personInfoMap);
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				int onDuty = Integer.parseInt(jedis.hmget("OTHER_DATA", "1").get(0));// 当班人数
				int onGuard = Integer.parseInt(jedis.hmget("OTHER_DATA", "2").get(0));// 在岗人数
				int waiting = Integer.parseInt(jedis.hmget("OTHER_DATA", "3").get(0));// 待岗人数

				int stationmasterAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "4").get(0));// 站长总任务数
				int stationmasterCom = Integer.parseInt(jedis.hmget("OTHER_DATA", "5").get(0));// 站长已完成
				int onDutyAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "6").get(0));// 值班员总任务数
				int onDutyCom = Integer.parseInt(jedis.hmget("OTHER_DATA", "7").get(0));// 值班员已完成
				int stationAttAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "8").get(0));// 站务员总任务数
				int stationAttCom = Integer.parseInt(jedis.hmget("OTHER_DATA", "9").get(0));// 站务员已完成

				int perSMAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "10").get(0));// 感知任务站长总任务数
				int perSMCom = Integer.parseInt(jedis.hmget("OTHER_DATA", "11").get(0));// 感知任务站长已完成
				int perODAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "12").get(0));// 感知任务值班员总任务数
				int perODCom = Integer.parseInt(jedis.hmget("OTHER_DATA", "13").get(0));// 感知任务值班员已完成
				int perSAAll = Integer.parseInt(jedis.hmget("OTHER_DATA", "14").get(0));// 感知任务站务员总任务数
				int perSACom = Integer.parseInt(jedis.hmget("OTHER_DATA", "15").get(0));// 感知任务站务员已完成

				JedisUtilProxy.close(jedis);
				int[] positionStatus = { onDuty, onGuard, waiting };
				String[] person = { "站长", "值班员", "站务员" };
				int[] planWork = { stationmasterAll, onDutyAll, stationAttAll };
				int[] planComplete = { stationmasterCom, onDutyCom, stationAttCom };
				int[] perceptionWork = { perSMAll, perODAll, perSAAll };
				int[] perceptionComplete = { perSMCom, perODCom, perSACom };
				personInfoMap.put("positionStatus", positionStatus);
				personInfoMap.put("person", person);
				personInfoMap.put("planWork", planWork);
				personInfoMap.put("planComplete", planComplete);
				personInfoMap.put("perceptionWork", perceptionWork);
				personInfoMap.put("perceptionComplete", perceptionComplete);
				dataMap.put("personInfoData", personInfoMap);
			}
			messageBean.setType("success");
			messageBean.setMessage("人员信息数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("人员信息数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 报障信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/workInfo")
	@ResponseBody
	public MessageBean getWorkInfoData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		Map<String, Object> workInfoMap = new HashMap<String, Object>();
		try {
			if ("test".equals(StartUpClass.workInfo)) {
				workInfoMap.put("fault", 100);
				workInfoMap.put("workOrder", 90);
				workInfoMap.put("processed", 80);
				dataMap.put("workInfoData", workInfoMap);
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				int fault = Integer.parseInt(jedis.hmget("OTHER_DATA", "22").get(0));// 已知故障
				int workOrder = Integer.parseInt(jedis.hmget("OTHER_DATA", "23").get(0));// 已发生工单
				int processed = Integer.parseInt(jedis.hmget("OTHER_DATA", "24").get(0));// 已处理工单
				JedisUtilProxy.close(jedis);
				workInfoMap.put("fault", fault);
				workInfoMap.put("workOrder", workOrder);
				workInfoMap.put("processed", processed);
				dataMap.put("workInfoData", workInfoMap);
			}
			messageBean.setType("success");
			messageBean.setMessage("任务信息数据获取成功");
			messageBean.setData(dataMap);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("任务信息数据获取失败");
		}
		return messageBean;
	}

	/**
	 * 首页任务信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "index/taskComp")
	@ResponseBody
	public MessageBean newWorkinfo() {
		MessageBean messageBean = new MessageBean();
		Map<String, Integer> result = new LinkedHashMap<String, Integer>();
		try {
			if ("test".equals(StartUpClass.taskComp)) {
				result.put("h_9_1_08", 10);
				result.put("h_1_1_08", 0);
				result.put("h_9_3_08", 46);
				result.put("h_1_3_08", 0);
				result.put("h_9_1_09", 4);
				result.put("h_1_1_09", 0);
				result.put("h_9_3_09", 68);
				result.put("h_1_3_09", 0);
				result.put("h_9_1_10", 1);
				result.put("h_1_1_10", 0);
				result.put("h_9_3_10", 32);
				result.put("h_1_3_10", 0);
				result.put("h_9_1_11", 0);
				result.put("h_1_1_11", 0);
				result.put("h_9_3_11", 1);
				result.put("h_1_3_11", 20);
			} else {
				Jedis jedis = null;
				try {
					jedis = JedisUtilProxy.getJedis();
				} catch (JedisNotInitializeException e) {
					e.printStackTrace();
				}
				Map<String, String> map = jedis.hgetAll("OTHER_DATA_TASKCOMP");
				Map<String, String> sortMap = new TreeMap<String, String>(
		                new Comparator<String>() {
		                    public int compare(String obj1, String obj2) {
		                        // 降序排序
		                        return obj1.compareTo(obj2);
		                    }
		                });		        
				sortMap.putAll(map);
				System.out.println(sortMap);
				Iterator entries = sortMap.entrySet().iterator(); 
				while (entries.hasNext()) { 
					Map.Entry entry = (Map.Entry) entries.next(); 
					 String key = (String)entry.getKey(); 
					 Integer value = Integer.parseInt((String)entry.getValue()); 
					result.put(key, value);
				}
			}
			messageBean.setType("success");
			messageBean.setMessage("实时任务完成情况数据获取成功");
			messageBean.setData(result);
			System.out.println(messageBean);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setMessage("任务信息数据获取失败");
		}
		return messageBean;
	}

	@RequestMapping(value = "index/getData")
	@ResponseBody
	public MessageBean getChartData() {
		MessageBean messageBean = new MessageBean();
		Map<String, Object> dataMap = new HashMap<String, Object>();
		// 系统总览
		Map<String, Object> systemOverview = new LinkedHashMap<String, Object>();
		systemOverview.put("FAS", true);
		systemOverview.put("PA", false);
		systemOverview.put("ACS", false);
		systemOverview.put("PIS", true);
		systemOverview.put("EMCS", true);
		systemOverview.put("CCTV", true);
		systemOverview.put("PSD", true);
		systemOverview.put("AFC", true);

		// 系统运营模式
		Map<String, Object> operationModeMap = new HashMap<String, Object>();
		String[] publicArea = { "空调季", "节能通风模式" };
		String intelligence = "节能模式";
		operationModeMap.put("publicArea", publicArea);
		operationModeMap.put("intelligence", intelligence);

		// 车站运营事件
		Map<String, Object> operationalEventMap = new LinkedHashMap<String, Object>();
		operationalEventMap.put("6:00", "一键开关站开站实行");
		operationalEventMap.put("6:30", "站厅扶梯1发生故障");
		operationalEventMap.put("7:00", "站厅扶梯2发生故障");
		operationalEventMap.put("7:30", "站厅扶梯3发生故障");

		// 车站客流模拟数据
		Map<String, Object> trendMap = new HashMap<String, Object>();
		String[] trendTime = { "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00" };
		int[] realTimeTrend = { 740, 738, 644, 344, 443, 541, 645 };
		int[] HistoryTrend = { 639, 643, 435, 438, 535, 442, 347 };
		int[] forecastTrend = { 446, 445, 337, 439, 541, 444, 347 };
		trendMap.put("trendTime", trendTime);
		trendMap.put("realTimeTrend", realTimeTrend);
		trendMap.put("HistoryTrend", HistoryTrend);
		trendMap.put("forecastTrend", forecastTrend);

		// 区域客流密度模拟数据
		Map<String, Object> densityMap = new HashMap<String, Object>();
		String[] areaDensity = { "出入口", "闸机", "扶梯", "售票机" };
		int[] passengerDensity = { 40, 70, 90, 50 };
		densityMap.put("areaDensity", areaDensity);
		densityMap.put("passengerDensity", passengerDensity);

		// 人员信息数据
		Map<String, Object> personInfoMap = new HashMap<String, Object>();
		int[] positionStatus = { 15, 10, 2 };
		String[] person = { "站长", "站务员", "值班员" };
		int[] planWork = { 80, 70, 100 };
		int[] planComplete = { 60, 50, 70 };
		int[] perceptionWork = { 70, 55, 75 };
		int[] perceptionComplete = { 70, 55, 75 };
		personInfoMap.put("positionStatus", positionStatus);
		personInfoMap.put("person", person);
		personInfoMap.put("planWork", planWork);
		personInfoMap.put("planComplete", planComplete);
		personInfoMap.put("perceptionWork", perceptionWork);
		personInfoMap.put("perceptionComplete", perceptionComplete);

		// 任务信息
		Map<String, Object> workInfoMap = new HashMap<String, Object>();
		workInfoMap.put("fault", 100);
		workInfoMap.put("workOrder", 90);
		workInfoMap.put("processed", 80);

		dataMap.put("systemOverviewData", systemOverview);
		dataMap.put("operationModeData", operationModeMap);
		dataMap.put("operationalEventData", operationalEventMap);
		dataMap.put("trendData", trendMap);
		dataMap.put("densityData", densityMap);
		dataMap.put("personInfoData", personInfoMap);
		dataMap.put("workInfoData", workInfoMap);
		messageBean.setType("success");
		messageBean.setData(dataMap);
		return messageBean;
	}
	
	@RequestMapping(value = "index/getPic")
	@ResponseBody
	public MessageBean getPic(HttpServletRequest request)
	{
		MessageBean messageBean = new MessageBean();
		String alarmId = request.getParameter("alarmId");
		String base64str = stationEventService.getPic(alarmId);
		if(org.apache.commons.lang3.StringUtils.isBlank(base64str))
		{
			messageBean.setType("error");
			messageBean.setMessage("图片不存在");
		}else {
			messageBean.setType("success");
			messageBean.setData(base64str);
		}
		return messageBean;
	}
}
